﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;
using Common.Utilities.Dispatcher;
using Workflows.Components.Entities.Properties;

namespace Workflows.Components.Entities.MasterData
{
    /// <summary>
    /// 
    /// </summary>
    [Serializable]
    public class DbProfileComponent:WorkflowComponentBase
    {
        private DbProfileInstruction _Instruction;
        public override InstructionBase Instruction
        {
            get { return _Instruction; }
            set { _Instruction=(DbProfileInstruction)value; }
        }

        private DbProfileOutput _Output;
        public override ResultBase Output
        {
            get { return _Output; }
            set { _Output=(DbProfileOutput) value; }
        }

        public DbProfileComponent():base()
        {
            this.ComponentActivityType = WorkflowActivityType.SimpleActivity;
            this.ComponentCategory = WorkflowComponentCategory.Entity_Relations.ToString();
            this.Description = "DB profiling";
            this.ComponentIcon = Resources.wdc_10024;
            this.ComponentImage = Resources.DatabaseSelectColumn48;
            this.ComponentName = "DB Profile";

            this._Instruction=new DbProfileInstruction(
                this.ComponentID,Guid.Empty,string.Empty,string.Empty,
                new Dictionary<string, List<string>>(), true,
                string.Empty,string.Empty, false, string.Empty);
            this._Output=new DbProfileOutput(
                this.ComponentID,Guid.Empty,string.Empty);
        }

        public override XmlNode Serialize(ref XmlDocument xDoc, ref XmlNode parentNode)
        {
            XmlNode xNode = base.Serialize(ref xDoc, ref parentNode);
            this.Instruction.Serialize(ref xDoc, ref xNode);
            return xNode;
        }

        public override WorkflowComponentBase Instantiate(XmlNode xNode)
        {
            DbProfileComponent component = (DbProfileComponent)base.Instantiate(xNode);
            component.Instruction = component.Instruction.Instantiate(xNode.SelectSingleNode("Instruction"));
            return component;
        }
    }
}
